function buildTree(nodes, parentId) {
        let tree = [];
        for (let node of nodes) {
            if (node.parentId === parentId) {
                let children = buildTree(nodes, node.menuId);
                if (children.length) {
                    node.children = children;
                }
                tree.push(node);
            }
        }
        return tree;
}

export default buildTree;